package com.ys.service.account.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.ys.dto.AddDto;
import com.ys.entity.account.TcwNeedPayAccount;
import com.ys.mapper.account.TcwNeedPayAccountMapper;
import com.ys.service.account.TcwNeedPayAccountService;
import com.ys.vo.R;

@Service("tcwNeedPayAccountService")
public class TcwNeedPayAccountServiceImpl implements TcwNeedPayAccountService {

	@Autowired
	private TcwNeedPayAccountMapper tcwNeedPayAccountMapper;
	
	/*
	 * 新增页
	 */
	@Override
	public R add(Map<String, Object> params) throws Exception {
		
		TcwNeedPayAccount entity = JSON.parseObject(JSON.toJSONString(params), TcwNeedPayAccount.class);

		tcwNeedPayAccountMapper.insert(entity);
		return R.ok(AddDto.closeAndReload());
	}
	
	/*
	 * 编辑页
	 */
	@Override
	@Transactional
	public R edit(Map<String, Object> params) throws Exception {
		TcwNeedPayAccount entity = JSON.parseObject(JSON.toJSONString(params), TcwNeedPayAccount.class);

		tcwNeedPayAccountMapper.update(entity);
		return R.ok("操作成功");
	}
}
